import React from "react";
import { addAction, subAction, asyncAddAction } from '../../redux/reducers/countReducer';
import store from "../../redux/store";

export default function Buttons() {
  //声明点击新增的函数
  let add = () => {
    store.dispatch(addAction(1));
  }

  let sub = () => {
    store.dispatch(subAction(1));
  }

  let addTen = () => {
    store.dispatch(asyncAddAction(10));
  }

  return (
    <>
      <button onClick={add}>增加</button>
      <button onClick={sub}>减少</button>
      <button onClick={addTen}>1秒后状态加 10</button>
    </>
  );
}
